Arduino PWM Output Filter Circuit
これまで、ArduinoベースのPWM出力にローパスフィルタと分圧回路を追加する機会が何度かあったので、他の場所で参照しやすいように、これらをひとつの投稿にまとめる価値があると思いました。これがその投稿です。ここに新しい内容はなく、これまでに行ったことを記録しているだけです。
警告! 実験には古いまたは中古の機器の使用を強くおすすめします。高価な機器が破損しても私は責任を負いません!
このプロジェクトで使用する主要なコンセプトに関する重要な過去のプロジェクトは以下のとおりです:
Arduinoを初めて扱う場合は、Getting Startedのページを参照してください。
There have been a number of occasions now where I’ve added a low-pass filter and voltage divider to my Arduino-based PWM outputs so I thought it was worth pulling that together into a single post to make it easy to refer to elsewhere. This is that post. There is nothing new here, it is just documenting things I’ve done elsewhere.
In part 2, I build the same circuit onto a proto shield.
Warning! I strongly recommend using old or second hand equipment for your experiments. I am not responsible for any damage to expensive instruments!
These are the key previous projects for the main concepts used in this project:
Mozzi Output Circuit – Part 2
Universal Microcontroller MIDI Module
If you are new to Arduino, see the Getting Started pages.
code:部品リスト
1×1.5kΩ抵抗(以前は270Ω)*
1×330Ω抵抗(以前は75Ω)*
1×68nFコンデンサ
1×10µF無極性コンデンサ
ブレッドボードとジャンパー線
*値については下記の議論を参照してください。
Parts list
1x 1.5K resistor (was 270Ω)*
1x 330Ω resistor (was 75Ω)*
1x 68nF capacitor
1x 10uF non-polar capacitor
Breadboard and jumper wires
See discussion below.
回路
The Circuit
https://gyazo.com/6827a923e13436bffbedd5ad5fb7982ahttps://gyazo.com/46782f7dc55a4eee28fb0679aee4bccc
また、電圧をよりオーディオに適したレベルに下げ、カップリングコンデンサを追加したいと考えています。そのため、最初の試みではMozzi回路にあった270Ωの抵抗と、新たに75Ωの抵抗をGNDへつないだ分圧回路を導入しました。
しかし、分圧回路を追加するとフィルタの特性も変わってしまいます。理論を厳密に追うわけではありませんが、分圧回路をテブナン等価抵抗 Thevenin equivalent resistance として扱う考え方があります。一般に、分圧回路の等価抵抗は、並列に接続された場合と同じ大きさとして考えられると示すことができるようです。
The original Mozzi Output Circuit used a 100nF capacitor and a 270Ω which gives a roll-off frequency of just under 6kHz. Using a 68nF capacitor ought to push that up to around 9kHz (see more here).
I want to also drop the voltage down to a more audio friendly level and add a coupling capacitor, so my initial attempt introduced a potential divider using the 270Ω resistor from the Mozzi circuit and an additional 75Ω resistor to GND.
But including a potential divider changes the properties of the filter too. A very hand-wavy (for me, I don’t follow the theory) way to think about it is to treat the potential divider as its Thevenin equivalent resistance. It (apparently) can be shown that the equivalent resistance for a potential divider can be considered to be the same as if the two resistors were in parallel.
これはつまり、フィルタの計算において「R」は実際には次の式で表されることを意味します:
$ R = \frac{R_1 R_2}{R_1 + R_2}
もとの値を用いた場合、これを計算するとおよそ 58Ω になります。この値をフィルタ計算に当てはめると、–3dB ポイントのロールオフ周波数は約 40kHz となります。つまり、このままではPWMキャリア周波数をまったく除去できません。
電圧を(ピーク5Vからおよそピーク1Vへ)約20%に落とすには、次の関係が必要です:
$ R_1 = 4 \, R_2 \,
したがって、必要な減衰を与えつつ等価抵抗を 270Ω にするには、以下の二つの式を連立します:
$ R = \frac{(4 \, R_2) \cdot R_2}{(4 \, R_2) + R_2}
$ = \frac{4 \, R_2^2}{5 \, R_2}
$ = \frac{4 \, R_2}{5}
ここで R = 270Ω とおくと、
$ 270 = \frac{4 \, R_2}{5} \,
となり、これを解くと
$ R_2 = \frac{5 \times 270}{4} = 338 \,\text{Ω}\,
$ R_1 = 4 \, R_2 = 4 \times 338 = 1350 \,\text{Ω}\,
手元の部品箱には 330Ω と 1.5kΩ の抵抗があったので、それらを使っています。この組み合わせでは合成抵抗は約 270.5Ω、減衰率は約 18%となります。
これは、0~5V のPWMような信号を想定した計算です。
私は「電子回路の専門家」ではないので、あくまで作業中のメモとして受け取ってください。しかし、この回路を使うことで、PWM出力からより実用的な電圧レベルで、ずっときれいな信号を得られるようになりました。
This means, that for filter calculation purposes, the “R” in the filter is actually equal to:
R = R1 * R2 / (R1 + R2)
In the case of the my original values, that comes to around 58Ω. Plugging that into a filter calculation gives a roll-off frequency (at the 3db point) of almost 40 KHz! That won’t filter out the PWM carrier frequency at all.
For a voltage reduction to around 20% (i.e. from 5V peak to around 1V peak) requires: R1 = 4 * R2, so to get an equivalent resistance of 270Ω whilst giving the required reduction, we can link the two equations together:
R = (4 * R2) * R2 / ((4 * R2) + R2) = 4 * R2 * R2 / (5 * R2) = 4 * R2 / 5
So 270 = 4 * R2 / 5 which means that R2 = 5 * 270 / 4 = 338Ω and therefore R1 = 1350Ω.
I have 330Ω and 1.5K resistors in my parts box, so I’m using those which is around 270.5Ω combined resistance and around a voltage reduction down to around 18%.
This is working on the assumption of a 0-5V input PWM like signal.
Recall that I’m not an “electronics person”, so treat this as a work in progress at best, but it seems to do the trick for me. I get a much nicer signal out of my PWM now at a much more useful voltage.
Kevin
https://gyazo.com/a1bf48a3bdb993a73a0f5b83d5bd692d